package com.wifi.user.service;

import com.wifi.user.dao.MenuDao;
import com.wifi.user.dao.MenuDaoImp;
import com.wifi.user.entity.Menu;

import java.sql.SQLException;
import java.util.List;

public class MenuServiceImpl implements  MenuService{
    MenuDao menuDao =new MenuDaoImp();
    @Override
    public List<Object> getMenu(int id) {
        try {
            return menuDao.selectMenuByUid(id);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return null;
    }

    @Override
    public long selectCount(String pid) {
        try {
            return  menuDao.selectCount(pid);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return 0;
    }

    @Override
    public List<Object> getMenuPage(Integer pageNum, Integer pageSize,String pid) {

        try {
            return menuDao.selectMenu(pageNum,pageSize,pid);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }return null;
    }

    @Override
    public Integer changeStatus(Integer id, Integer status) {
        try {
            return menuDao.changeStatus(id,status);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }return 0;
    }

    @Override
    public List<Object> getMenufather() {
        try {
            return menuDao.selectFatherMenu();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }return null;
    }

    @Override
    public Long addMenu(Menu menu) {
        try {
            return menuDao.insertMenu(menu);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }return Long.valueOf(0);
    }

    @Override
    public Object getMenu(String name,Integer role) {
        try {
            return menuDao.selectMenu(name,role);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }return null;
    }

    @Override
    public Object getMenuByMid(Integer role) {
        try {
            return menuDao.selectMenuByMid(role);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }return null;
    }

    @Override
    public Integer editMenu(Menu menu) {
        try {
            return menuDao.updateMenu(menu);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }return 0;
    }

    @Override
    public long addMbyU(Integer uid, Integer mid){
        try {
            return menuDao.insertUserMenu(uid,mid);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }return 0;
    }

    @Override
    public Integer emptyByUid(Integer valueOf) {
        try {
            return menuDao.DeleteEmptyByid(valueOf);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }return 0;
    }
}
